import * as loginService from '../services/user';
import router from 'umi/router';

export default {
  namespace: 'login',
  state: {},
  reducers: {

  },
  effects: {
    *checkAuth ({},{ call, put }){
      const res = yield call(loginService.checkAuth, { mac: "2c-9d-1e-0f-ea-bf" });
      console.log("检查授权----", res);
    },

    *login ({ payload: { tel, password } }, { call, put }) {
      const res =  yield call(loginService.login, {tel, password});
      console.log("res----", res);
      const { ok, msg } = res.data;
      if(ok) {
        router.push('/');
      }
    }
  }
}
